package com.jf3q.sup.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jf3q.sup.domain.Carriers;
import com.jf3q.sup.dto.CarriersPageDto;
import com.jf3q.sup.service.CarriersService;
import com.jf3q.sup.mapper.CarriersMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

/**
 *
 */
@Service
public class CarriersServiceImpl extends ServiceImpl<CarriersMapper, Carriers>
    implements CarriersService{

    @Autowired
    CarriersMapper carriersMapper;

    @Override
    public Page getPage(CarriersPageDto pageDto) {
        LambdaQueryWrapper<Carriers> lambdaQueryWrapper=new LambdaQueryWrapper<>();
        lambdaQueryWrapper.like(Carriers::getName,pageDto.getName());
        lambdaQueryWrapper.like(Carriers::getContactName,pageDto.getContactName());
        if(StringUtils.hasText(pageDto.getPhone())){
            lambdaQueryWrapper.eq(Carriers::getPhone,pageDto.getPhone());
        }
        return carriersMapper.selectPage(new Page<Carriers>(pageDto.getPageNow(),3),lambdaQueryWrapper);
    }
}




